seq = ''
for i in range(1,2023+1):
    seq += str(i)

s = ''
for t in seq:
    if t in ['2','0','2','3']:
        s += t

"""分别代表 2 20 202 2023"""
dp = [0]*4
for t in s:
    if t=='2':
        dp[0] += 1
        dp[2] += dp[1]  # 以2为结尾
    if t=='0':  # 为0为结尾
        dp[1] += dp[0]
    if t=='3': # 以3为结尾
        dp[3] += dp[2]
print(dp[-1])